const express = require('express');
const fs = require('fs');
const path = require('path');
const tool = require('../../../tool.js');

const router = express.Router();

router.post('/application/AppStore/allApps', (req, res) => {

    const filePath = path.join(__dirname, '../../app-repo.json');
    if (tool.isFile(filePath)) {
        fs.readFile(filePath, (err, data) => {
            if (err) {
                res.send(err);
            } else {
                res.setHeader('ContentType', 'application/json');
                res.send(data);
            }
        });
    }
});

module.exports = router;
